this.source = source;
this.title = title;
this.urgency = Urgency.NORMAL;
- this.resident = false;
// 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
this.isTransient = false;
this.privacyScope = PrivacyScope.USER;
this._soundFile = null;
this._soundPlayed = false;
this.actions = [];
+ this.setResident(false);
// If called with only one argument we assume the caller
// will call .update() later on. This is the case of
setResident(resident) {
this.resident = resident;
+
+ if (this.resident) {
+ if (this._activatedId) {
+ this.disconnect(this._activatedId);
+ this._activatedId = 0;
+ }
+ } else if (!this._activatedId) {
+ this._activatedId = this.connect_after('activated', () => this.destroy());
+ }
}
setTransient(isTransient) {
activate() {
this.emit('activated');
- if (!this.resident)
- this.destroy();
}
destroy(reason = NotificationDestroyedReason.DISMISSED) {
+ if (this._activatedId) {
+ this.disconnect(this._activatedId);
+ delete this._activatedId;
+ }
+
this.emit('destroy', reason);
+ this.run_dispose();
}
});
_hideNotificationCompleted() {
let notification = this._notification;
this._notification = null;
- if (notification.isTransient)
+ if (!this._notificationRemoved && notification.isTransient)
notification.destroy(NotificationDestroyedReason.EXPIRED);
this._pointerInNotification = false;